package com.samebuilding.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.samebuilding.dao.GiftDAO;
import com.samebuilding.domain.Gift;

public class GiftDAOImpl extends HibernateDaoSupport implements GiftDAO{



	public Gift findByCode(int code) {
		List list=this.getHibernateTemplate().find("from Gift as g where g.code=?",code);
		if(list!=null&&list.size()>0)
			return (Gift)list.get(0);
		return null;
	}

	public List findBygiftCategoryCode(int giftCategoryCode) {
		List list=this.getHibernateTemplate().find("from Gift as g where g.giftCategoryCode=?",giftCategoryCode);
		if(list!=null&&list.size()>0)
			return list;
		return null;
	}
	public void save(Gift g){
		this.getHibernateTemplate().save(g);
	}

	public Gift findByName(String name) {
		List list=this.getHibernateTemplate().find("from Gift as g where g.name=?",name);
		if(list!=null&&list.size()>0)
			return (Gift)list.get(0);
		return null;
	}

	public List findAll() {
		
		return this.getHibernateTemplate().find("from Gift");
	}

}
